
#ifndef FXT_SERVER_SERVER_HPP__
# define FXT_SERVER_SERVER_HPP__

# ifndef _WIN32_WINNT
#  define _WIN32_WINNT 0x0501
# endif // _WIN32_WINNT

#include <memory>

#include <boost/asio.hpp>

#include "server/Session.hpp"

namespace Fxt {
	namespace Server {
		class Server {
		public:
			Server(short port);
			virtual ~Server();

		public:
			void run();
			void sessionClosed();

		private:
			void startAccept();
			void handleAccept(boost::system::error_code const & error);

		public:
			boost::asio::io_service& ios();

		private:
			short _port;
			boost::asio::io_service _ios;
			boost::asio::ip::tcp::acceptor _acceptor;
			std::shared_ptr<Session> _session;
		};
	}
}

#endif // FXT_SERVER_SERVER_HPP__
